package com.example.common.slice;

import com.example.common.ResourceTable;
import com.example.commonlib.base.ToolbarAbility;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;


public class CatalogAbilitySlice extends ToolbarAbility {
    // 整个页面
    private ComponentContainer detailLayout;
    private Text first;
    private Text second;
    private Text third;
    private Text forth;
    private Text fifth;
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);

        // 由于无法直接 通过 RsId setUI, 所以 通过下面获取componentContainer，再set
        LayoutScatter getLayoutInflater = LayoutScatter.getInstance(getContext());
        detailLayout = (ComponentContainer)getLayoutInflater.parse(ResourceTable.Layout_slice_catalog, null, false);

        // 设置是否显示状态页
        setStatusPageEnable(false);

        // set UI
        setUIContent(detailLayout);
        // 设置显隐藏 返回
        setToolbarHomeBack(true);
        // 设置 tilte
        setTitle(ResourceTable.String_courseDirListTitle);
        // 设置左侧icon
        setLeftIcon(ResourceTable.Media_iconBack);
        // 隐藏右侧按钮
        setRightVisibility(false);



        first = (Text) findComponentById(ResourceTable.Id_text1);
        second = (Text) findComponentById(ResourceTable.Id_text2);
        third = (Text) findComponentById(ResourceTable.Id_text3);
        forth = (Text) findComponentById(ResourceTable.Id_text4);
        fifth = (Text) findComponentById(ResourceTable.Id_text5);

        first.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                intentDetail();
            }
        });
        second.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                intentDetail();
            }
        });
        third.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                intentDetail();
            }
        });
        forth.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                intentDetail();
            }
        });
        fifth.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                intentDetail();
            }
        });
    }

    // toolbar 继承返回点击事件
    @Override
    public void backEvent(){
        // 返回
        super.onBackPressed();
    }

    public void intentDetail(){
        present(new DetailAbilitySlice(), new Intent());
//        terminate();
    }
}
